Creating a fixed value from variables after entering a trade.

 

Greetings again to all community members...

i would really appreciate some assistance on a problem that has been making me crack my head for too long without any success... maybe its just a simple tweek for some but being a newcomer this is a bit tough for me.

my problem is...

1. Im not using a fixed stop loss condition to enter a trade, rather the stoploss condition is determined at the point of entry as described below...example for a BUY trade..

Ticket1=OrderSend(Symbol(),OP_BUY,(AllowedLot12*FLotB1/(HargaBuka_0 - MA12L_1)*PNTvalue),Ask,Slippage,MA12L_1,Ask+TakeProfit*PNTvalue,"",2890,0,Green);

2. I'd like to record the difference between OrderOpenPrice() and the initial stoploss, MA12L_1 as the "INITIALGAP".... (note: the MA12L_1 value will definitely be lower than OrderOpenPrice value to avoid error)

3.Then i'd like to call this fixed value 'INITIALGAP" to set the trailingstop condition and new Stoploss as the trade moves into +ve gain until it reaches the breakeven level, afterwhich a separate fixed trailingStop will be used

<SNIP>

this is then folowed by other instructions.....

Hopefully i have clearly stated my logic to avoid confusion.

Thanks A million...

 
jayakaa:

Greetings again to all community members...

i would really appreciate some assistance on a problem that has been making me crack my head for too long without any success... maybe its just a simple tweek for some but being a newcomer this is a bit tough for me.

my problem is...

1. Im not using a fixed stop loss condition to enter a trade, rather the stoploss condition is determined at the point of entry as described below...example for a BUY trade..

Ticket1=OrderSend(Symbol(),OP_BUY,(AllowedLot12*FLotB1/(HargaBuka_0 - MA12L_1)*PNTvalue),Ask,Slippage,MA12L_1,Ask+TakeProfit*PNTvalue,"",2890,0,Green);

2. I'd like to record the difference between OrderOpenPrice() and the initial stoploss, MA12L_1 as the "INITIALGAP".... (note: the MA12L_1 value will definitely be lower than OrderOpenPrice value to avoid error)

3.Then i'd like to call this fixed value 'INITIALGAP" to set the trailingstop condition and new Stoploss as the trade moves into +ve gain until it reaches the breakeven level, afterwhich a separate fixed trailingStop will be used

<SNIP>

this is then folowed by other instructions.....

Hopefully i have clearly stated my logic to avoid confusion.

Thanks A million...

Please edit your post . . . .


Please use this to post code . . . it makes it easier to read.

 
RaptorUK:
Please edit your post . . . .


Please use this to post code . . . it makes it easier to read.



Dear RaptorUK, i'm including my code here....just need a guide on how to use the "INITIALGAP" as a constant during the trade...

thanks You


	          
 
jayakaa:


Dear RaptorUK, i'm including my code here....just need a guide on how to use the "INITIALGAP" as a constant during the trade...

thanks You

You can include your code, that isn't a problem . . but please use the SRC button to do it . . .
 
RaptorUK:
You can include your code, that isn't a problem . . but please use the SRC button to do it . . .

Hi RaptorUk, once i copy and paste the entire code using SRC, i cant add the comments as the error message says ..its too long.... therefore i have attached the code file instead...sorry for teh inconvenience...
 
jayakaa:
Hi RaptorUk, once i copy and paste the entire code using SRC, i cant add the comments as the error message says ..its too long.... therefore i have attached the code file instead...sorry for teh inconvenience...
Thank you :-)
 
RaptorUK:
Thank you :-)


Hi Raptor, any recommendation on how to go about getting th efixed value?
Reason: