avoid multiple entries  [SOLVED]

Questions about MultiCharts and user contributed studies.
moreno
Posts: 22
Joined: 29 May 2019
Has thanked: 19 times

avoid multiple entries

Postby moreno » 03 Oct 2020

Hi friends,
I have searched for this subject in the forum but didn't manage to solve this riddle...:
using two-time frames where the entry condition provided by the second,
which makes usually several entries, but I want to use just the first entry and ignore others from that signal.
all this of course until the entry condition meets again maybe on the same day.
using Renko chart (I don't think it matters...).

the code:

Code: Select all

inputs: Price( Close ), Length( 14 ), OverSold( 30 ) ; variables: RSI20(0,data2); RSI20 = RSI(Price, Length )data2; condition2 = RSI20[1] < RSI20 and RSI20[1]<RSI20[2] and RSI20[1]<OverSold ; if condition2 then Buy ( "RsiLE" ) this bar at close ;

sptrader
Posts: 742
Joined: 09 Apr 2010
Location: Texas
Has thanked: 483 times
Been thanked: 274 times
Contact:

Re: avoid multiple entries

Postby sptrader » 04 Oct 2020

Maybe something like "if marketposition = 0 and condition2 then buy".

moreno
Posts: 22
Joined: 29 May 2019
Has thanked: 19 times

Re: avoid multiple entries

Postby moreno » 04 Oct 2020

Thanks sptrader.
I tried it (""if marketposition = 0 and condition2 then buy"") and still multiple entries.
I suppose that is because after I close each position (take small profit) then "marketposition" (data1) turns 0 again while the condition based on data2 is still true.
and order repeats...

Mydesign
Posts: 177
Joined: 15 Feb 2017
Has thanked: 32 times
Been thanked: 39 times

Re: avoid multiple entries

Postby Mydesign » 05 Oct 2020

Hi,

Several options, beside the marketposition condition:

- Try to unckeck "Allow up to xxx entry orders inthe same direction" option in Strategy properties.
- If you leave it checked, make sure to select the option "When the order is generated by a different entry order".
- Add a boolean variable that changes state after 1st entry and use it as a condition.

Generally speaking, you'd better try to code your signal condition as an "event" (when condition goes from false to true) rather than just a "state" (condition is true)...

moreno
Posts: 22
Joined: 29 May 2019
Has thanked: 19 times

Re: avoid multiple entries  [SOLVED]

Postby moreno » 05 Oct 2020

Thanks, Mydesign, but it didn't work.
the challenge here because of strategy properties/position limits uses "currently held position" situation
while my orders filled quickly and the market position turns flat ("0") before the solutions above refer.

BUT you gave me the idea I couldn't think of (it was a late night...)
e.g. - refer to data2 constraint and add "condition2 <> condition2[1]".
the code here work well.

Code: Select all

inputs: Price( Close ), Length( 14 ), OverSold( 30 ) ; variables: RSI20(0,data2); RSI20 = RSI(Price, Length )data2; condition2 = RSI20[1] < RSI20 and RSI20[1]<RSI20[2] and RSI20[1]<OverSold ; if condition2 and condition2 <> condition2[1] then Buy ( "RsiLE" ) this bar at close ;
Thanks for your help.

Mydesign
Posts: 177
Joined: 15 Feb 2017
Has thanked: 32 times
Been thanked: 39 times

Re: avoid multiple entries

Postby Mydesign » 06 Oct 2020

[...] and add "condition2 <> condition2[1]"
Here you go ! Glad I could help :D


Return to “MultiCharts”