NexusFi: Find Your Edge


Home Menu

 





Very confused---stop wont move with the candles


Discussion in Platforms and Indicators

Updated
    1. trending_up 1,437 views
    2. thumb_up 0 thanks given
    3. group 1 followers
    1. forum 0 posts
    2. attach_file 0 attachments




 
Search this Thread

Very confused---stop wont move with the candles

  #1 (permalink)
bondstrader
Dubai, UAE
 
Posts: 10 since Sep 2014
Thanks Given: 2
Thanks Received: 1

Hopefully someone can help me out of this.
In the following code opening a long position if the current price is higher than the previous candle's High.
Then I set a profit target, and a stop loss. The profit target is static, so that works fine, but the stop loss is variable. I have set it to look for the lowest price of the last 5 candles, and set that as a stop loss. However, in my code, what it does is that it sets the stop loss based on the lowest price of the 5 candles before the trade candle, and fixes it at that value.
I want the stop to keep on moving with each candle, i-e, after each candle, it evaluates the lowest value of the last 5 candles and sets the stop as that....
Any ideas on what Im missing, or what I need to add to the following code to achieve that?

 
Code
	OrderSelect(LongTicket,SELECT_BY_TICKET);
		
		if (OrderCloseTime() != 0 || LongTicket == 0)
		{    

bool buy_condition_1 = Ask >= High[1]; 

 if( buy_condition_1)
			{
							
		      LongTicket = OrderSend(Symbol(),OP_BUY,LotSize,Ask,0,0,0,"Buy Order",MagicNumber,0,Green);
		      OrderSelect(LongTicket,SELECT_BY_TICKET); 
		      double OpenPrice = OrderOpenPrice();
                      double LongStopLoss =  Low[iLowest(NULL,0,MODE_LOW,5,1)];
                      double LongTakeProfit = OpenPrice + (TakeProfit * TickPoints);
            
				if(LongStopLoss > 0 || LongTakeProfit > 0) 
				{
                       bool LongMod = OrderModify(OrderTicket(),OpenPrice,LongStopLoss, LongTakeProfit,0);
				}
		
			}
		}

Reply With Quote




Last Updated on September 1, 2015


© 2024 NexusFi™, s.a., All Rights Reserved.
Av Ricardo J. Alfaro, Century Tower, Panama City, Panama, Ph: +507 833-9432 (Panama and Intl), +1 888-312-3001 (USA and Canada)
All information is for educational use only and is not investment advice. There is a substantial risk of loss in trading commodity futures, stocks, options and foreign exchange products. Past performance is not indicative of future results.
About Us - Contact Us - Site Rules, Acceptable Use, and Terms and Conditions - Privacy Policy - Downloads - Top
no new posts