Moving stop loss to x pips away from previous HA bar

Section for discussions related to indicators, use of indicators, and building of trading stategies using indicators.

Moderator: admin

Moving stop loss to x pips away from previous HA bar

Postby nanobyt3 » Fri Mar 03, 2017 4:41 pm

Hi all, :)

I have been developing a strategy in lua for FXCM Trading Station and I'm having problems moving a stop loss to few pips (customizable) away from a previous HeikenAshi bar. I have the following:

Code: Select all
   --Trailing the SL to x PBT pips from the previous bar
   if haveTrades("B") then
         valuemap.PegTypeStop = "O";
         valuemap.PegPriceOffsetPipsStop = iHA.low[period]-PBT;
         core.host:trace("Moving Stop Loss Higher to ".. tostring(iHA.low[period]-PBT));
      end


PBT is the variable with the number of PIPs away from the low as in this case. the log shows me big number when trying to add the iHA.low[period]+PBT. This number does not seem to be related to price.

Any good link for me to learn how to move the Stop Loss to whatever position I need?

Thank you very much
nanobyt3
 
Posts: 1
Joined: Fri Mar 03, 2017 4:28 pm

Re: Moving stop loss to x pips away from previous HA bar

Postby rog9912345 » Sat Apr 25, 2020 7:20 pm

Did you manage to solve this? I'm trying to do something similar-ish (no success here yet).
rog9912345
 
Posts: 1
Joined: Sat Apr 25, 2020 7:11 pm

Re: Moving stop loss to x pips away from previous HA bar

Postby Apprentice » Sun Apr 26, 2020 6:16 am

Your request is added to the development list.
Development reference 1147.
User avatar
Apprentice
FXCodeBase: Confirmed User
 
Posts: 36258
Joined: Thu Dec 31, 2009 11:59 am
Location: Zagreb, Croatia

Re: Moving stop loss to x pips away from previous HA bar

Postby Apprentice » Tue Apr 28, 2020 10:19 am

if side == "B" then
valuemap.RateStop = iHA.low[period] - PBT * iHA.lowpipSize();
else
valuemap.RateStop = iHA.high[period] + PBT * iHA.lowpipSize();
end
User avatar
Apprentice
FXCodeBase: Confirmed User
 
Posts: 36258
Joined: Thu Dec 31, 2009 11:59 am
Location: Zagreb, Croatia

Re: Moving stop loss to x pips away from previous HA bar

Postby dab13fx » Tue May 19, 2020 10:14 pm

does by any chance you guys know one that i will move every 1 HR candle for example


thanks
dab13fx
 
Posts: 3
Joined: Tue May 19, 2020 10:07 pm

Re: Moving stop loss to x pips away from previous HA bar

Postby Apprentice » Mon May 25, 2020 6:27 am

Your request is added to the development list.
Development reference 1352.
User avatar
Apprentice
FXCodeBase: Confirmed User
 
Posts: 36258
Joined: Thu Dec 31, 2009 11:59 am
Location: Zagreb, Croatia

Re: Moving stop loss to x pips away from previous HA bar

Postby Apprentice » Mon May 25, 2020 7:01 am

Code: Select all
function Prepare()
    Source = ExtSubscribe(2, nil, TF, instance.parameters.Type == "Bid", "bar");
end
function ExtUpdate(id, source, period)
    if id == 2 then
        --move stop
    end
end
User avatar
Apprentice
FXCodeBase: Confirmed User
 
Posts: 36258
Joined: Thu Dec 31, 2009 11:59 am
Location: Zagreb, Croatia


Return to Discussions

Who is online

Users browsing this forum: No registered users and 7 guests