Check if hit stop limit  [SOLVED]

Questions about MultiCharts and user contributed studies.
kinwai
Posts: 89
Joined: 03 May 2019
Has thanked: 12 times
Been thanked: 1 time

Check if hit stop limit  [SOLVED]

Postby kinwai » 20 Feb 2021

I want to do something after hit stop limit, I tried to use exitname(1), but it always returns same job name.

Anyone can advise how I can execute some codes immediately after hit the stop limit hit?

Code: Select all

sell(“JobName”) next bar at xxx limit

User avatar
Kate MultiCharts
Posts: 575
Joined: 21 Oct 2020
Has thanked: 7 times
Been thanked: 144 times

Re: Check if hit stop limit

Postby Kate MultiCharts » 24 Feb 2021

Hello kinwai,

Here's an example you can refer to:

Code: Select all

var: intrabarpersist mp(0); if mp<0 and marketposition=0 then begin // sell exit hit end; mp = marketposition;

kinwai
Posts: 89
Joined: 03 May 2019
Has thanked: 12 times
Been thanked: 1 time

Re: Check if hit stop limit

Postby kinwai » 11 May 2021

Hi Kate,

I had tried it before, the statement is okay to check if hits stop limit. However, every bar returns true from “mp<0 and marketposition=0” until we open next trade, so my sell exit hit logic will execute in every bar, but I only want to execute once after hit the logic.

Any thought?

kinwai
Posts: 89
Joined: 03 May 2019
Has thanked: 12 times
Been thanked: 1 time

Re: Check if hit stop limit

Postby kinwai » 05 Jun 2021

At the end, it works when I changed mp<0 to mp>0

But when I tried to put the last statement “mp - marketposition” at the beginning, then it doesn’t work, anyone has idea?

Code: Select all

var: intrabarpersist mp(0); mp = marketposition; if mp>0 and marketposition=0 then begin // sell exit hit end;


Return to “MultiCharts”