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

Testing of Mr Larry Williams Formula

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

    Testing of Mr Larry Williams Formula

    Hi Everybody,

    I am testing the Larry Williams formula for entry strategy of
    following:
    Larry Williams Formula
    Inputs: Length(16),
    PH( ( ( (H+L+C) / 3) * 0) - L),
    PL( ( ( (H+L+C) / 3) * 0) - H);


    But is not working. Can anybody help to find out
    what is wrong.
    Thank you very much.


    #region Variables

    private DataSeries williamPH ;
    private double william_PH_highestValue = 0;

    protected override void Initialize()
    {
    williamPH = new DataSeries(this);

    CalculateOnBarClose = true;

    }
    protected override void OnBarUpdate()
    {

    //LONG CRITERIA


    if (Position.MarketPosition == MarketPosition.Flat)
    {
    SetStopLoss("PositionLong1",CalculationMode.Ticks, 20,false);
    SetProfitTarget("PositionLong1",CalculationMode.Ti cks, 10000);

    }

    // Resets the highest high at the start of every new session
    if (Bars.FirstBarOfSession)

    williamPH[0]= ( ( ( (High[0]+Low[0]+Close[0]) / 3) * Open[0]) - Low[0]);


    // Stores the highest high from the first 16 bars
    if (Bars.BarsSinceSession < 16
    && williamPH[0] >William_PH_highestValue )
    {
    William_PH_highestValue = williamPH[0];
    }

    // Entry Condition: Submit a buy stop order one tick above the first 30 bar high. Cancel if not filled within 34 bars.
    if (Bars.BarsSinceSession > 16 && Bars.BarsSinceSession < 50
    &&Position.MarketPosition == MarketPosition.Flat)
    {
    EnterLongStop(DefaultQuantity, William_PH_highestValue+2*TickSize,"PositionLong1" );
    InitialStopPrice = Low[1]-100*TickSize;
    ProTarget =2.5*( InitialStopPrice);

    SetStopLoss("PositionLong1", CalculationMode.Price, initialStopPrice, false);
    SetProfitTarget("PositionLong1", CalculationMode.Price, ProTarget);
    }

    }

    #2
    Hello ArthurMFTse,

    Thank you for your post and welcome to the forums!

    You would want to some run debugs through your script to ensure that you are getting the correct results from your calculations that you are expecting -

    First of all you would want to use Print() statements to verify values are what you expect - Debugging your NinjaScript code.

    It may also help to add drawing objects to your chart for signal and condition confirmation - Drawing Objects.
    Cal H.NinjaTrader Customer Service

    Comment


      #3
      The formula is false. (H+L+C) / 3) * O) would be a squared price and have a false dimension. The correct formulas for projected high and low are

      PP = (H + L + C) / 3
      PH = PP * 2 - L
      PL = PP * 2 - H

      Those levels are identical with the floor pivots R1 and S1. If you wish to calculate them from the regular session high, low and the settlement price, please use the SessionPivots indicator that can be found in the download section.

      Comment


        #4
        Thanks Ninjatrader_Cal and Harry.
        I will test agsin for the correct formula.
        Good Days.

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by lorem, Yesterday, 09:18 AM
        3 responses
        13 views
        0 likes
        Last Post lorem
        by lorem
         
        Started by cmtjoancolmenero, Yesterday, 03:58 PM
        12 responses
        42 views
        0 likes
        Last Post NinjaTrader_ChelseaB  
        Started by FrazMann, Today, 11:21 AM
        0 responses
        5 views
        0 likes
        Last Post FrazMann  
        Started by geddyisodin, Yesterday, 05:20 AM
        8 responses
        52 views
        0 likes
        Last Post NinjaTrader_Gaby  
        Started by DayTradingDEMON, Today, 09:28 AM
        4 responses
        27 views
        0 likes
        Last Post DayTradingDEMON  
        Working...
        X