How to code? - page 243

 

Help to improve ATR indic!!!

I am trying to code an improved version of the ATR indicator. I want to be able to have the ATR indicator but based only on the candle from 2:00 am to 11:00 am for a period P.

For example: on an hourly chart I want an to find the ATR over 120 periods (+/- 120 hours = 5days) but only with the bars between 2:00 am to 11:00 am during those 120 hours.

If anybody has an idea how to modify the standard ATR code to do what I am trying to do... please answer to this post with you code...

Thanks...

 

Ea

Pls, which expression can be used to obtain the open or high price of a candlestick which is X bars from the most recent fractal candlestick? (pls write the full expression... I'm just asking for one or two lines)

Thanks

 
ak_marshal:
Pls, which expression can be used to obtain the open or high price of a candlestick which is X bars from the most recent fractal candlestick? (pls write the full expression... I'm just asking for one or two lines) Thanks

First of all you need to check what is the index of fractal bar. For this you should use loop you can use "while" or "for". I will use for.

for(int i = 0;i<Bars;i++)

{

double isfractal = code for reading fractals;

if(isfractal != 0)

{

double myOpen = Open;//this will be your X where XBarsAfterFractal is integer number - x bars from the fractal bar.

break;//exit from loop

}

}

 

Help with a very simple script please

Hi Guys,

Can someone please help with CoderGurus script below.

It works great as it is but I wanted to modify it so that it will stop the stop loss and profit take based on the opening price of the trade, not the current bid and ask prices.

As I said, it works fine as is, I thought I would just have to change OrderModify(OrderTicket(),OrderOpenPrice(),Bid-Point*StopLoss,Bid+Point*TakeProfit,0,Green); to

OrderModify(OrderTicket(),OrderOpenPrice(),OrderOpenPrice()-Point*StopLoss,OrderOpenPrice()+Point*TakeProfit,0,Green);

but when I try and run it nothing happens.

Can someone please point me in the right direction.

Thanks

Steve

//+------------------------------------------------------------------+

//| My_First_Script.mq4 |

//| Copyright Coders Guru |

//| https://www.mql5.com/en/forum |

//+------------------------------------------------------------------+

#property copyright "Copyright Coders Guru"

#property link "https://www.forex-tsd.com"

#property show_inputs

#include

extern double TakeProfit=250;

extern double StopLoss=35;

//+------------------------------------------------------------------+

//| script program start function |

//+------------------------------------------------------------------+

int start()

{

int total,cnt,err;

double stop_loss_value;

double take_profit_value;

total = OrdersTotal();

for(cnt=0;cnt<total;cnt++)

{

OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES);

if(OrderType()==OP_BUY) // long position is opened

{

OrderModify(OrderTicket(),OrderOpenPrice(),Bid-Point*StopLoss,Bid+Point*TakeProfit,0,Green);

err=GetLastError();

Print ("High - ");

Print("error(",err,"): ",ErrorDescription(err));

Sleep(1000);

}

if(OrderType()==OP_SELL) // short position is opened

{

OrderModify(OrderTicket(),OrderOpenPrice(),Ask+Point*StopLoss,Ask-Point*TakeProfit,0,Red);

err=GetLastError();

Print("error(",err,"): ",ErrorDescription(err));

Sleep(1000);

}

}

return(0);

}

 

How can i make function as loop

i want to use function EA that working as loop like this :

(for now i use varible

INT trend)

A >> B >> C >> D >> E

i use A = new high + SMA30 > 80

i "buy " trend = 1

then B = sma30 < 80

i " sell" trend = 2

then C = sma30>80

i "buy " trend = 3

at C is the point that iwant it t check

if it make new high at any place i wnat return trend to be 1 and looping it

if it not make new high it will go to sma30 < 80

and go to trend = 4

////////////

this is loop that i want can anyone tell me function to use (my way that use variable not function and don't know why)

hope for wise advise , thak you

 

I could not follow your logic, but maybe this example can be used to help you:

MA30=iMA(NULL,0,30,0,0,0,0);

MA80=iMA(NULL,0,80,0,0,0,0);

if(High[0]>High[1] && MA30>MA80) A=1;

if(MA30<MA80) B=2;

if(MA30>MA80) C=3;

Maybe you can work with this to expand it to your desired loop result.

 

set current date as extern var ?

Hi all i was after some help in modifying some code. The problem is every time i open this particular EA i have to manually change the time and date, What i wanted to know is if it was possible to make this auto update every time the EA is opened?

To be more specific the EA opens a buy and sell pending at the pre determined time and date, changing the time isnt so bad, but when attaching the EA to 5 or 6 charts it can get a little bit annoying, and copy/paste isnt going to cut it long term

extern datetime NewsTime = D'05.08.2010 10:15'; is the code

Any help appreciated

 

May be write a script, which set a global variable with a new date (GlobalVariableSet), and add to EA reading of this variable (GlobalVariableGet)?

 

CAn someone chnage the Trade comment parameter

Hi,

I have a signal copier EA , that copies exact Trade comment from Master. I need to add an External paramater to this EA, that can set to any Trade comment I want. I would really appreciate if somebody helps.

Thanks

Files:
s-mtfx_s.mq4  27 kb
 
Ale:
May be write a script, which set a global variable with a new date (GlobalVariableSet), and add to EA reading of this variable (GlobalVariableGet)?

thanks, but i thought the problem is external variables like "NewsTime" wont accept anything other than a static variable

you could set it using the script, but then you couldnt change it ?

is that correct?