NexusFi: Find Your Edge


Home Menu

 





Problem with a High formula set


Discussion in NinjaTrader

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




 
Search this Thread

Problem with a High formula set

  #1 (permalink)
 olres7 
Gatlinburg TN/USA
 
Experience: Intermediate
Platform: NinjaTrader
Trading: Futures
Posts: 12 since Sep 2015
Thanks Given: 5
Thanks Received: 0

I want to go short when the previous High[1] more than 21 Highs in a row and the range between previous High[1] and Low[1] less than 2 points

I tried many times, however all the time I have an error.

if( High[1] > High[2] ...High[21] && High[1]-Low[1]<2)
{
EnterShortLimit(GetCurrentBid(), "Short");
Print(Time[0]+" Sell");
}

Or I tried this way:

if( High[1]>High[2] &&
High[1]>High[3] &&
High[1]>High[4] &&
High[1]>High[5] &&
...
High[1]>High[21] &&
High[1] - Low[1] <2
{
EnterShortLimit(GetCurrentBid(), "Short");
Print(Time[0]+" Sell");
}

On second example it complies correct however it doesn't give me correct results. It doesn't go short when the previous high higher than 21 highs and the range lower than 2 points

Please help me to fix this issue
My code idea is this:

Started this thread Reply With Quote

Can you help answer these questions
from other members on NexusFi?
ZombieSqueeze
Platforms and Indicators
The space time continuum and the dynamics of a financial …
Emini and Emicro Index
NexusFi Journal Challenge - April 2024
Feedback and Announcements
My NT8 Volume Profile Split by Asian/Euro/Open
NinjaTrader
Futures True Range Report
The Elite Circle
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Get funded firms 2023/2024 - Any recommendations or word …
61 thanks
Funded Trader platforms
39 thanks
NexusFi site changelog and issues/problem reporting
26 thanks
The Program
18 thanks
GFIs1 1 DAX trade per day journal
18 thanks
  #3 (permalink)
 
Fat Tails's Avatar
 Fat Tails 
Berlin, Europe
Market Wizard
 
Experience: Advanced
Platform: NinjaTrader, MultiCharts
Broker: Interactive Brokers
Trading: Keyboard
Posts: 9,888 since Mar 2010
Thanks Given: 4,242
Thanks Received: 27,102


It is not possible to deal with the question, as the information that you have give is not sufficient.

Please show the entire code section for OnBarUpdate(), otherwise the bugs cannot be identified.

Further it is crucial to understand, whether you plan to run your strategy with CalculateOnBarClose set to "True" of "False".

Reply With Quote
Thanked by:
  #4 (permalink)
 olres7 
Gatlinburg TN/USA
 
Experience: Intermediate
Platform: NinjaTrader
Trading: Futures
Posts: 12 since Sep 2015
Thanks Given: 5
Thanks Received: 0

protected override void Initialize()
{
CalculateOnBarClose = true;
SetStopLoss("", CalculationMode.Ticks, 4, false);
SetProfitTarget("", CalculationMode.Ticks, 15);

}

protected override void OnBarUpdate()
{

if(

//First Condition - Previous High[1] Higher than 21 highs
High[1]>High[2] &&
High[1]>High[3] &&
High[1]>High[4] &&
High[1]>High[5] &&
High[1]>High[6] &&
High[1]>High[7] &&
High[1]>High[8] &&
High[1]>High[9] &&
High[1]>High[10] &&
High[1]>High[11] &&
High[1]>High[12] &&
High[1]>High[13] &&
High[1]>High[14] &&
High[1]>High[15] &&
High[1]>High[16] &&
High[1]>High[17] &&
High[1]>High[18] &&
High[1]>High[19] &&
High[1]>High[20] &&
High[1]>High[21] &&

//Second Condition - Difference between previous High[1] - Low[1] <2 points
High[1] - Low[1] <2)
{
// Go short when 2 conditoins are true
EnterShortLimit(GetCurrentBid(), "Short");
Print(Time[0]+" Sell");
}

}//End OnBarUpdate

Even it complies correct however it doesn't give me correct results. It doesn't go short when the previous high higher than 21 highs and the difference between high and low lower than 2 points.

It go short on a completely wrong price
Please help me to fix this issue

Started this thread Reply With Quote
  #5 (permalink)
 
Fat Tails's Avatar
 Fat Tails 
Berlin, Europe
Market Wizard
 
Experience: Advanced
Platform: NinjaTrader, MultiCharts
Broker: Interactive Brokers
Trading: Keyboard
Posts: 9,888 since Mar 2010
Thanks Given: 4,242
Thanks Received: 27,102

This script should not run, as for bars smaller than 20 (CurrentBar < 20), it will produce a runtime error.

What do you call a point? Which instrument did you apply it to?


Also you can simplify the code to

 
Code
if(CurrentBar < 21)
     return;

if(High[1] > MAX(High, 20)[2] && Range()[1] > 2)
     EnterShortLimit(GetCurrentBid(), "Short");

Reply With Quote
Thanked by:
  #6 (permalink)
 olres7 
Gatlinburg TN/USA
 
Experience: Intermediate
Platform: NinjaTrader
Trading: Futures
Posts: 12 since Sep 2015
Thanks Given: 5
Thanks Received: 0

Hi!

I am writing my own strategy. It is almost done.
However the last thing I have left is a daily loss limit.
I have the example of it.
However even it is complies good and doesn't have any mistakes it still works with wrong results

It works great with 1 Order - IOrder (shortOrder1)
Daily STOP LOSS = 200

However if I have 2 orders 2 IOrder (shortOrder1 and shortOrder2)
It will automatically make this command for each order

shortOrder1 = 200 daily loss
shortOrder2 = 200 daily loss

So total my loss will be 400

I want total of these orders do not go over 200

IF <DAILY STOP LOSS OVER 200> THEN <STOP TRADING>

(shortOrder1 + shortOrder1) <= 200 Stop Loss

I tried many times different things and they didn't work

I trade for today - 11/02/2015
I had a HUGE LOSS THIS DAY and my DAILY LOSS LIMIT didn't help me
My strategy works on a 5 Min interval

How can I do that in order total orders do not go over 200 daily loss?

Pls help me to figure out that issue.

SCRIPT FILE ATTACHED

Thanks,
Serge

Attached Files
Elite Membership required to download: DailyLossLimit.txt
Started this thread Reply With Quote




Last Updated on November 2, 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