PDA

View Full Version : Need Help in Coding!



solmac2808
08-13-2008 10:03, 10:03 AM
I've created a very straightforward EA. . And a system which I use in 3 Timeframe..May difficulty it doesn't stop opening and I don't wish to have 3 EA and 3 chart for a single pair. .

I want a code which would just do one order each bar per TF and still open if it's on another bar. .

Occasionally I have 3 sign in 3 different TF. . I want to have all order but I want only order each TF and I can still take another order exactly the same TF if it's still open but in another bar. .

Instance:
1 sign in 4h
1 sign in 1h but it drops in bar for 4h
1 sign in 30 min but just one bar for 1h and 4h. .

I am fine with using magicnumber

can someone help me? Thank you very much. .

pilisanchis
08-07-2023 13:11, 01:11 PM
I will have a peek at that.

Nabucogokllom35
08-07-2023 14:32, 02:32 PM
I will take a peek at that.
Thank you. . Hope to hear from you. .

Nabucogokllom35
08-07-2023 15:53, 03:53 PM
Anyone that has a code?

Nabucogokllom35
08-07-2023 17:13, 05:13 PM
What can I do with this code? Or I am not using the code. .

Time(OrderOpenTime()) = iTime(Symbol(),PERIOD_M30,0)

Nabucogokllom35
08-07-2023 18:34, 06:34 PM
I think that my explaination is poor. . Try to explain

I need a code that can take a minumum of one order for buy and sell per pub. .

But a few times I have 3 sign for one pub in greater TF cause I use 3 TF and each has different signs but it falls on precisely the exact same pub for greater TF.

So far that is my solution:
I am okay with using magic number as a piece of filter.

Can someone help me? Thank you very much.

So far that is what I thought:
for 30 mins
if (magicnumber == 123)

if (iTime(OrderOpenTime()) ! ) = iTime(Symbol(),PERIOD_M30,0))
//my order code



I do not possess MT4 but I know somethings isn't right in the logic or code. So guys please help me.

Gopi10
08-07-2023 19:55, 07:55 PM
Would this job???

Int init()

LastBuyTime = 0;
LastSellTime = 0;


int start()

if (Buy Requirements Met)

if (Period [0] gt; LastBuyTime) //check the time of past buy order
//process order
OrderSend(blah blah blah);
if (No Error) LastBuyTime = Time[0];


//repeat the Exact Same for Sell
return(0);

Gopi10
08-07-2023 21:16, 09:16 PM
In the event you use separate EA for different time frame, then the above code should work
if it works, it ought to be better in comparison to sending information to in your server all the time to inspect the OrderOpenTime()??

But if you use the same EA for different time frame
afterward in the event that you want to do the same with every time frame then either use arrays
ie. LastBuyTime[Stage ()]
or in the event that you only exchange 3 time frame then use
LastBuyTimeM15
LastBuyTimeH1
LastBuyTimeH4
etc.etc. .


If the array method is too messy as it creates 240 arrays if you exchange 4 hour chart, then you need separate code to automatically convert interval () to an integer, ie. 1minute=0, 5 minute =1, 15min = two etc.etc. And utilize this integer to reference the array...

Gopi10
08-07-2023 22:36, 10:36 PM
And if you're afraid that there is too many ticks happening in exactly the exact same second, then you might also record the Volume down [0] of this moment when you last put the order to be certain it will not put 2 orders at the exact same second...

Nabucogokllom35
08-07-2023 23:57, 11:57 PM
I will use one EA and a single chart to exchange 3 TF. .

Anyways, I do not know a lot about variety and therefore I will try the last code you posted. . It'd be appreciated, if you can give me a bit of details about how to attach. . Thank you. .

Nabucogokllom35
08-08-2023 01:18, 01:18 AM
I have a question. .

Would current time be equal to pub?

Ei:

int init()

LastBuyTime = 0;
LastSellTime = 0;


int start()

if (OrderOpentime() gt; LastBuyTime30) //assess time of last buy order

LastBuyTime30 = OrderOpenTime ()

should LastBuyTime30 lt; iTime(,period,0) (magicnumber ! ) = 123)
the buy order condition
return(0);

Gopi10
08-08-2023 02:39, 02:39 AM
In the event you exchange 3 time frame using one chart using the identical EA, it becomes much more complied, as Time[0] returns the beginning time of the current un-closed candle on your chart, thus you will require some code to filter out the period range of every candle.
The dilemma is not as complied if you exchange just 15min, hourly daily, coz if you inserted the EA from the 15min chart, then you can use the TimeHour() function to filter out the hour of the previous tick and it's rather easy...
but should you exchange 4hour and 1hour chart in the same time, then you will need more code, ie. (NormalizeDouble(TimeHour(TimeCurrent())/4),0) * 4 will return the start time of the current 4 hour candle, then you have to use this value and with the purpose DayOfYear Year to store the time when you last entered an order when triggered by 4 hour sign...

Gopi10
08-08-2023 03:59, 03:59 AM
The solution for your issue seem very complied... if you have to trade 3 different time frames using a single chart...

note: the example is still trying to recover the Last order time in the server (OrderOpenTime()) which I don't recommend as it generates extra network traffic and may create unneccesary network traffic for your own server if your EA is looped too many times per second

Nabucogokllom35
08-08-2023 05:20, 05:20 AM
the remedy to your problem seem very complied... in case you must trade 3 different time frames with a single chart...

notice: your case is still hoping to recover the previous order time in the server (OrderOpenTime()) that I don't recommend as it creates extra network traffic and may produce unneccesary network traffic to your server in case your EA is looped a lot of times per minute Thank you. . I like your idea but the problem is I am not good at coding. .

If you show me a basic on how best to attach what your posted here. . I don't know how to code arrays. . Thank you. .

Another question what should my EA or MT4 reset? At the same time it required order will it require yet another order ?

Nabucogokllom35
08-08-2023 06:41, 06:41 AM
Can somebody stop this from modifing my order over and over again? Can someone give me assistance on code to get step? Like do trail stop every 10 pips or 5 pips instead of 1 pips. . Can someone give me a code?


void BEM ()

int pips;
for (int k=0; klt;OrdersTotal ();k )

OrderSelect(k, SELECT_BY_POS, MODE_TRADES);
if(OrderType()==OP_BUY OrderSymbol()== Symbol () OrderMagicNumber()== Magic)

pips = (Bid - OrderOpenPrice())/Stage;
if ((pips gt;= BE) (OrderStopLoss() lt; OrderOpenPrice()))

OrderModify (OrderTicket (), OrderOpenPrice (),OrderOpenPrice () 12*Stage, OrderTakeProfit (), 0, LightBlue);


if(OrderType()==OP_SELL OrderSymbol()== Symbol () OrderMagicNumber()== Magic)

pips = (OrderOpenPrice() - Ask)/Stage;
if ((pips gt;= BE) (OrderStopLoss() gt; OrderOpenPrice()))

OrderModify (OrderTicket (), OrderOpenPrice (),OrderOpenPrice ()- 12*Stage, OrderTakeProfit (), 0, Pink);

Gopi10
08-08-2023 08:02, 08:02 AM
Arrays is exactly like a variable, except that you use one variable name and utilize a number to reference all the principles, Time[], High[], Low[], Open[], Close[] etc.etc are examples of variable

I'd like to help more, but I've been very busy, and it's difficult for me to help you in the event that you do not understand how to apply what I've suggested, you'll need to read the documentation on mq4 to attempt and learn more about the coding for now. .

Gopi10
08-08-2023 09:22, 09:22 AM
another question what if my EA or MT4 reset? At precisely the same time it required order will it require yet another order again?
Your EA must have codes, that when it first loads to assess if any sign happen to be triggered with the most recent candle, and if so, resets the trigger/counter, hence preventing the EA from ever opening orders/creating alerts on the instance that the EA is loaded. .

Nabucogokllom35
08-08-2023 10:43, 10:43 AM
thanks. . If you do not mind. . You can post an EA here with range I can study the code from that point. .

Anyways, you have been of great help. .

Nabucogokllom35
08-08-2023 12:04, 12:04 PM
Can anyone give me the code for measure? One was created by me before but it loops and loops

Gopi10
08-08-2023 13:25, 01:25 PM
thanks.. If you do not mind. . Perhaps you can post an EA here I could study the code from there. . Array is just as any other factor, hard to give an illustration
if you declare a variable, instead of int MyValues, you declare it as int MyValues[n] instead, in which n is the number of factors in your array,
so instead of having MyValues1=1.5400; MyValues2=1.5450; MyValues3=1.5520;
you could get an array, declare it as int MyValues[3]
then MyValues[1]=1.5400; MyValues[two ]=1.5450; MyValues[3]=1.5520;

it may look silly, but if you're coping with a lot of values, it seems sensible...

Gopi10
08-08-2023 14:46, 02:46 PM
Just thought of an example. .


//storing the range of Former candlesup to a maximum of last 100 candles
int numBars;
dual Range[100];
if (Bars gt; 100) numBars=100; otherwise numBars=Bars;
for (int n=0; n lt; numBars; n ) Range[n] = High[n] - Low[n];

Nabucogokllom35
08-08-2023 16:06, 04:06 PM
Dragon?

thanks. . I get confuse. . I tried to make one. . Stuck to nothing. . Hehe

anyways, I move to a new problem which is fractals. .

Can array be utilized to store the latest 3 fractal upward and 3 fractal down?

A person gave me a loop to get this. . But when I read your article, I must go with looping. .
Https://www.nigeriaforextrading.com/trading-system-and-egies/102-account-managers-trades-signals.html

is there a crash course to learn array? Aside from mql4 that is the closes thing that is upcoming. .

Nabucogokllom35
08-08-2023 17:27, 05:27 PM
Can anybody help me? Prepared to pay to create the code. . thank you