Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

Partner 728x90

Collapse

Trading a PIN bar logic not working

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Trading a PIN bar logic not working

    Hello: I have this code that not working and only prints a log when I am not in Trade. What is missing so at least I get one trade.
    Logic to check the current bar open, close, high and low and see if high of the bar have formed Wick and place a trade long or short.
    Any syntax error causing it or something missing in the code. I build this using some Youtube videos but something is not right.
    Any help would be appreciated.
    Thanks,

    protected override void OnBarUpdate()
    {
    if (BarsInProgress != 0)
    return;

    if (CurrentBars[0] < 1)
    return;

    Print("I am in NO trade.");


    if ((Close[0] == Low[0] && Open[0] > Close[0] && High[0] > Open[0] && CrossAbove(Close, MY_EMA, 1)))
    {
    EnterLong(Convert.ToInt32(DefaultQuantity), @"Buy");
    Print("I am in LONG trade.");

    }

    if ((Close[0] == High[0] && Open[0] < Close[0] && High[0] > Open[0] && CrossBelow(Close, MY_EMA, 1)))
    {
    EnterShort(Convert.ToInt32(DefaultQuantity), @"Sell");
    Print("I am in SHORT trade.");
    }



    // Set 6
    // if (BarsSinceExitExecution(0, "", 0) == 1)
    // {
    // Draw.Text(this, Convert.ToString(CurrentBars[0]), Convert.ToString(SystemPerformance.AllTrades.Trade sPerformance.Currency.CumProfit) + @" $", 0, (Low[0] + (25 * TickSize)) );
    // }

    }

    #2
    Hello mtamaku,

    The print "Print("I am in NO trade.");" should be appearing for every bar update.

    The entry order is only going to be submitted if the condition is evaluating as true.

    One line above the condition print the time of the bar and print each value being compared in the condition. Include labels for each value and comparison operator.

    We should be able to see in the output how each value is being compared.

    Below is a link to a forum post with videos that demonstrate how to use prints to understand behavior.


    Save the output to a text file and include this with your reply.
    Chelsea B.NinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by llanqui, Today, 03:53 AM
    0 responses
    4 views
    0 likes
    Last Post llanqui
    by llanqui
     
    Started by burtoninlondon, Today, 12:38 AM
    0 responses
    10 views
    0 likes
    Last Post burtoninlondon  
    Started by AaronKoRn, Yesterday, 09:49 PM
    0 responses
    14 views
    0 likes
    Last Post AaronKoRn  
    Started by carnitron, Yesterday, 08:42 PM
    0 responses
    11 views
    0 likes
    Last Post carnitron  
    Started by strategist007, Yesterday, 07:51 PM
    0 responses
    14 views
    0 likes
    Last Post strategist007  
    Working...
    X