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

Strategy HeikhinAshi

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

    Strategy HeikhinAshi

    I programmed the following strategy
    When I activate the strategy, it is deactivated within seconds.

    Can someone help me?​


    public class HeikhinAshiLong : Strategy
    {
    private double HAOpen;
    private double HAClose;
    private double VHAOpen;
    private double VHAClose;
    private double HAHigh;
    private double HALow;


    ************************************************

    protected override void OnBarUpdate()
    {
    HAOpen = (Open[1] + Close[1])/2;
    HAClose = (Open[0] + Close[0] + High[0] + Low[0])/4;
    HAHigh = Math.Max(Highs[0][0], HAOpen);
    HAHigh = Math.Max(HAHigh, HAClose);
    HALow = Math.Min(Lows[0][0], HAOpen);
    HALow = Math.Min(HALow, HAClose);
    VHAOpen = (Open[2] + Close[2])/2;
    VHAClose = (Open[1] + Close[1] + High[1] + Low[1])/4;


    if (BarsInProgress != 0)
    return;

    if (CurrentBars[0] < 1)
    return;

    // set 1
    if ((HAClose > HAOpen)
    && (VHAClose < VHAOpen))
    {
    EnterLong(1, @"PosEröffnen");
    EnterShortStopMarket(1, 120, @"StoppOrder");
    Draw.Ray(this, @"HekhinAshi240Long Gerade_1", false, 0, 0, 0, 0, Brushes.CornflowerBlue, DashStyleHelper.Solid, 2);
    }

    // set 2
    if ((VHAClose > VHAOpen)
    && (HAClose < HAOpen))
    {
    EnterShort(1, @"Order schliessen");
    }​


    ​​

    #2
    Hello Christopher_R,

    Thank you for your post and welcome to the NinjaTrader forum community!

    Since the strategy is becoming disabled right after enabling it, please check the Log tab of the Control Center for error messages. If there are errors, what do they report?
    • To send a screenshot with Windows 10 or newer I would recommend using the Windows Snipping Tool.
    • Alternatively to send a screenshot press Alt + PRINT SCREEN to take a screenshot of the selected window. Then go to Start--> Accessories--> Paint, and press CTRL + V to paste the image. Lastly, save it as a jpeg file and send the file as an attachment.
    ​I look forward to your reply.
    Emily C.NinjaTrader Customer Service

    Comment


      #3
      Thank you...

      There are no errors. The strategy deactivates itself within seconds.

      Here, are the printscreens of the sources:

      Click image for larger version

Name:	image.png
Views:	17
Size:	73.5 KB
ID:	1295216
      Click image for larger version

Name:	image.png
Views:	16
Size:	27.5 KB
ID:	1295217​​

      Comment


        #4
        Hello Christopher_R,

        Thank you for your reply.

        We do not provide hands-on debugging assistance, though we are glad to guide you through the debugging process to understand unexpected behavior. I suggest adding print statements to your strategy and opening the NinjaScript Output window prior to enabling your strategy. Please review which print statements appear in the window as well as if there are any particular messages giving a clue as to why it is becoming disabled. For more information about using prints for debugging, please see the article here:


        If you'd like, I'd be glad to review your log and trace files for any information related to this strategy becoming disabled. These files contain helpful diagnostic information that could also help us understand why this is happening. These files can be sent through the platform by going to the Control Center-> Help-> Email Support. Ensuring 'Log and Trace Files' is checked will include these files. This is checked by default. If you send them, please be sure to include "ATTN Emily" in the subject line with a link to this forum thread in the body of the email.

        Please feel free to reach out with any additional questions or concerns.​
        Emily C.NinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by carnitron, Today, 08:42 PM
        0 responses
        5 views
        0 likes
        Last Post carnitron  
        Started by strategist007, Today, 07:51 PM
        0 responses
        6 views
        0 likes
        Last Post strategist007  
        Started by StockTrader88, 03-06-2021, 08:58 AM
        44 responses
        3,974 views
        3 likes
        Last Post jhudas88  
        Started by rbeckmann05, Today, 06:48 PM
        0 responses
        8 views
        0 likes
        Last Post rbeckmann05  
        Started by rhyminkevin, Today, 04:58 PM
        4 responses
        58 views
        0 likes
        Last Post dp8282
        by dp8282
         
        Working...
        X